#ifndef _MQTT_CJSON_HANDLE_H_
#define _MQTT_CJSON_HANDLE_H_

#include "cJSON.h"
#include "mqtt_client.h"
#include "string.h"
#include "radar.h"

enum{
    ERR_SUCCESS                    = 0,     //成功
    ERR_FAIL                       = 5000,	//失败
    ERR_DEVICE_NOT_FOUND           = 5001,	//找不到设备
    ERR_DEVICE_OFFLINE             = 5002,	//设备离线
    ERR_PARAMETER_OUT_OF_RANGE     = 5003,	//参数超出范围
    ERR_BUSY_OR_TIMEOUT            = 5004,	//繁忙/超时
    ERR_UNSUPPORTED_COMMAND_NUMBER = 5005,	//不支持的命令号
    ERR_OTHER_UNKNOWN_ERRORS       = 5006,	//其他未知错误
};

extern void mqtt_heartbeat_report(void* arg);//心跳
extern void mqtt_data_parse(char *topic, char *data);
extern void parse_data_push_set(char *data);
extern void mqtt_protocal_radar_attr(esp_mqtt_client_handle_t client, char *radar_rate, uint32_t radar_value);
extern void mqtt_protocal_radar_attr_str(esp_mqtt_client_handle_t client, char *radar_rate, char *radar_value_str);
extern void mqtt_protocal_radar_event(esp_mqtt_client_handle_t client, char *radar_event, uint32_t radar_flat);
extern void control_set_ota_ack(esp_mqtt_client_handle_t client,int success,char *ver);

extern void mqtt_protocal_sleepreport_analysis(esp_mqtt_client_handle_t client, char *sleepreport);
extern void event_mqtt_report(int event_type);

extern void radar_data_cJSON_Create(int sn);
extern void cJSON_creat_online(void);
extern void cJSON_creat_sync(void);
extern void cJSON_creat_heartbeat(void);
extern void cJSON_creat_error(uint16_t code);
extern void cJSON_creat_attr(char *item, int value);
extern void cJSON_creat_event(char *item, int value);
extern void cJSON_creat_report(report_attr_t report, cJSON *data);
extern void cJSON_creat_raw(void);

#endif


